import type { ConsultInfo } from "@/types/consult"
import { defineStore } from "pinia"
import { ref } from "vue"

export const useConsultStore = defineStore(
  "consult",
  () => {
    // 表单默认值
    const defaultIllnessInfo: ConsultInfo = {
      illnessDesc: "", // 疾病描述
      illnessTime: 1, // 患病时间
      consultFlag: 0, // 是否就诊过
      pictures: [], // 图片
    }
    // 表单数据
    const illnessInfo = ref<ConsultInfo>({ ...defaultIllnessInfo })
    // 咨询类型
    const type = ref("")
    // 科室 id
    const depId = ref("")
    // 三甲 普通 医院类型
    const illnessType = ref("")
    // 患者id
    const patientId = ref("")

    // 清除数据
    const clear = () => {
      // 重置表单数据
      illnessInfo.value = { ...defaultIllnessInfo }
      // 清除其他数据
      type.value = ""
      depId.value = ""
      illnessType.value = ""
      patientId.value = ""
    }
    return {
      defaultIllnessInfo,
      illnessInfo,
      type,
      depId,
      illnessType,
      patientId,
      clear,
    }
  },
  {
    unistorage: true,
  }
)
